#ifndef BCOMBOXDELEGATE_H
#define BCOMBOXDELEGATE_H

#include <QStyledItemDelegate>
#include <QObject>

class BComboxDelegate : public QStyledItemDelegate
{
    Q_OBJECT
public:
    explicit BComboxDelegate(QObject* parent = nullptr);

private:
    QStringList m_list;
    bool m_isEditable = false;
public:
    void setItems(QStringList items, bool isEdit);
    //自定义代理组件继承的4个必须函数

    virtual QWidget* createEditor(QWidget *parent,
                 const QStyleOptionViewItem &option,
                 const QModelIndex &index) const override;

    virtual void setEditorData(QWidget *editor,
                               const QModelIndex &index) const override;
    virtual void setModelData(QWidget* editor,
                              QAbstractItemModel *model,
                              const QModelIndex &index) const override;

    virtual void updateEditorGeometry(QWidget *editor,
                                      const QStyleOptionViewItem &option,
                                      const QModelIndex &index) const override;



};

#endif // BCOMBOXDELEGATE_H
